Skip to content

fix: drag limitation on mousemove#128

Open
Delgado-tech wants to merge 5 commits into
hxf31891:mainfrom
Delgado-tech:main
Open

fix: drag limitation on mousemove#128
Delgado-tech wants to merge 5 commits into
hxf31891:mainfrom
Delgado-tech:main

Conversation

@Delgado-tech

Copy link
Copy Markdown

The original version had a pretty limiting behavior — when interacting with the color picker (like dragging the saturation square, hue, opacity sliders, etc.), your mouse had to stay inside the component. If you moved outside, everything just froze until you came back.

With this fork, that’s no longer a problem. Now you can drag freely, even outside the component.

I also took the chance to adjust some TypeScript typings along the way.

💡 Note: In this fork, I migrated the project's package manager from Yarn to PNPM

const handleOpacity = (x: number) => {
if (opacityRef.current) {
const newO = getHandleValue(x, opacityRef.current, barSize) / 100
console.log(newO)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove console.log

zdila added a commit to zdila/react-gradient-color-picker that referenced this pull request Jun 10, 2026
Replaces the separate mouse (and partial touch) handlers across the hue,
opacity, gradient and advanced sliders and the saturation square with a
single Pointer Events code path. This brings full mobile/touch support
(PRs hxf31891#130 and hxf31891#132) while preserving PR hxf31891#128's "drag outside the
component" behaviour via global pointermove/pointerup listeners.

- onPointerDown + global pointermove/pointerup listeners everywhere
- touch-action: none on draggable elements to prevent page scrolling
  while dragging on touch devices
- drop the stray console.log left in Opacity

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
zdila added a commit to zdila/react-gradient-color-picker that referenced this pull request Jun 10, 2026
- rename package to the @Freemap scope, v3.1.0, point repository/bugs/
  homepage at FreemapSlovakia, publishConfig.access=public
- update README install/import/badges and describe the fork + merged PRs
- drop unused lodash.throttle dependency (removed by PR hxf31891#128)
- bump dependencies via ncu (tinycolor2 1.6, React 19 dev types, etc.);
  keep TypeScript on 5.x since TS 6 rejects the intentional ES5 target
- add pnpm-workspace.yaml so pnpm 11 builds esbuild and skips the
  pre-run deps check

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@zdila

zdila commented Jun 11, 2026

Copy link
Copy Markdown

👋 Heads-up: I've published a maintained fork that bundles this PR together with #129, #130 and #132, since they're still open upstream.

Thanks @Delgado-tech — your "drag outside the component" fix (and the Yarn → pnpm migration) is the base of the fork. On top of it I unified the slider/square input on Pointer Events (mouse + touch + pen), upgraded to TypeScript 6, refreshed dependencies, and fixed a corner-reachability bug in the saturation square (pure white was previously unreachable).

This is an unofficial community fork, not affiliated with the upstream maintainer — published simply to help anyone who needs these changes now. Happy to upstream any of it if a maintainer would like.

(Fork prepared with Claude Code.)

zdila added a commit to zdila/react-gradient-color-picker that referenced this pull request Jun 11, 2026
PR hxf31891#128 (our base) commented out the old keyboard/focus based point
deletion, leaving the trash button in GradientControls as the only way to
remove a stop — and nothing happened when double-clicking a handle dot.
Wire onDoubleClick on the handle to the existing deletePoint (single click
already selects the dot, so double-click removes it; a 2-stop gradient is
left intact).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants